package com.lythen.test.geo.es.controller;

import com.lythen.test.geo.es.component.GeoDataService;
import com.lythen.test.geo.es.entity.GeoDataEntity;
import org.opengis.referencing.FactoryException;
import org.opengis.referencing.operation.TransformException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.text.ParseException;
import java.util.List;

/**
 * <h3>geo-elasticsearch</h3>
 * <p></p>
 *
 * @author : lythen
 * @date : 2022-07-14 23:24
 **/
@RestController
@CrossOrigin
@RequestMapping("geo")
public class GeoDataController {
    @Autowired
    GeoDataService geoDataService;

    @GetMapping("save")
    public String save() throws IOException, ParseException {

        geoDataService.Insert();
        return  "success";
    }
    @GetMapping("search")
    public List<GeoDataEntity> getData(@RequestParam("name") String cityName){
        return geoDataService.query(cityName);
    }
    @GetMapping("mapQuery")
    public List<GeoDataEntity> mapQuery() throws FactoryException, IOException, TransformException {
        return geoDataService.queryMap();
    }
}
